<?php

use Biz\Constants\Site\SiteMemberConstants;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * SiteMember.
 *
 * @license [http://www.85do.com] [杭州永奥网络科技有限公司]
 * @copyright Copyright (c) 2018-2026 Hangzhou Yongao Technology Co., Ltd. All rights reserved.
 */
class SiteMember extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('site_member', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('site_id');//站点ID
            $table->unsignedBigInteger('user_id');// 用户ID
            $table->tinyInteger('status')->default(SiteMemberConstants::STATUS_NORMAL);//状态
            $table->timestamps();

            //外键约束
//            $table->foreign('site_id')->references('id')->on('app_site')
//                ->onUpdate('CASCADE')->onDelete('CASCADE');
//
//            $table->foreign('user_id')->references('id')->on('user')
//                ->onUpdate('CASCADE')->onDelete('CASCADE');

            //普通索引
            $table->index('site_id');
            $table->index('user_id');
            $table->index(['site_id', 'user_id']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('site_member');
    }
}